package com.ghck.server.model;

import java.lang.reflect.Field;
import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ghck.server.model.response.IdNameRes;
import com.google.gson.Gson;
/**
 * 疾病库表  <br>
 * t_disease <br>
 * v1.0 2016-05-01
 */
 public class Disease extends BaseModel{
	
	private static final long serialVersionUID = 1L;
	
 	private static Logger logger = LoggerFactory.getLogger(Disease.class);
 	//id
	private Integer id;

 	//疾病名称
 	//name
	private String name;

 	//系统名称,医学界名称
 	//system_name
	private String systemName;

 	//年龄特征
 	//age_symp
	private String ageSymp;

 	//性别特征性,0 无 1 男  2 女
 	//sex_symp
	private String sexSymp;

 	//简介
 	//disease_desc
	private String diseaseDesc;

 	//出处
 	//book_msg
	private String bookMsg;

 	//症状
 	//symptom
	private String symptom;

 	//危害
 	//endanger
	private String endanger;

 	//治疗
 	//treatment
	private String treatment;

 	//预防
 	//prevent
	private String prevent;

 	//药物推荐
 	//medcine_rec
	private String medcineRec;

 	//关键字
 	//keywords
	private String keywords;

 	//患病几率
 	//odds
	private String odds;

 	//是否在用,0：未使用,1：正在使用
 	//in_used
	private Integer inUsed;

 	
 	//last_modify_time
	private Date lastModifyTime;

 	
 	//create_time
	private Date createTime;

	private List<DictDiseaseKey> dictDiseaseKeyList;
	
	private List<IdNameRes> bodyparts;
	
	/**
	*
 	*id
 	*/
	public Integer getId() {
		return id;
	}
	
	/**
	*
 	*id
 	*/
	public void setId(Integer id) {
		this.id = id;
	}
	
	/**
	*疾病名称
 	*name
 	*/
	public String getName() {
		return name;
	}
	
	/**
	*疾病名称
 	*name
 	*/
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	*系统名称,医学界名称
 	*system_name
 	*/
	public String getSystemName() {
		return systemName;
	}
	
	/**
	*系统名称,医学界名称
 	*system_name
 	*/
	public void setSystemName(String systemName) {
		this.systemName = systemName;
	}
	
	/**
	*年龄特征
 	*age_symp
 	*/
	public String getAgeSymp() {
		return ageSymp;
	}
	
	/**
	*年龄特征
 	*age_symp
 	*/
	public void setAgeSymp(String ageSymp) {
		this.ageSymp = ageSymp;
	}
	
	/**
	*性别特征性,0 无 1 男  2 女
 	*sex_symp
 	*/
	public String getSexSymp() {
		return sexSymp;
	}
	
	/**
	*性别特征性,0 无 1 男  2 女
 	*sex_symp
 	*/
	public void setSexSymp(String sexSymp) {
		this.sexSymp = sexSymp;
	}
	
	/**
	*简介
 	*disease_desc
 	*/
	public String getDiseaseDesc() {
		return diseaseDesc;
	}
	
	/**
	*简介
 	*disease_desc
 	*/
	public void setDiseaseDesc(String diseaseDesc) {
		this.diseaseDesc = diseaseDesc;
	}
	
	/**
	*出处
 	*book_msg
 	*/
	public String getBookMsg() {
		return bookMsg;
	}
	
	/**
	*出处
 	*book_msg
 	*/
	public void setBookMsg(String bookMsg) {
		this.bookMsg = bookMsg;
	}
	
	/**
	*症状
 	*symptom
 	*/
	public String getSymptom() {
		return symptom;
	}
	
	/**
	*症状
 	*symptom
 	*/
	public void setSymptom(String symptom) {
		this.symptom = symptom;
	}
	
	/**
	*危害
 	*endanger
 	*/
	public String getEndanger() {
		return endanger;
	}
	
	/**
	*危害
 	*endanger
 	*/
	public void setEndanger(String endanger) {
		this.endanger = endanger;
	}
	
	/**
	*治疗
 	*treatment
 	*/
	public String getTreatment() {
		return treatment;
	}
	
	/**
	*治疗
 	*treatment
 	*/
	public void setTreatment(String treatment) {
		this.treatment = treatment;
	}
	
	/**
	*预防
 	*prevent
 	*/
	public String getPrevent() {
		return prevent;
	}
	
	/**
	*预防
 	*prevent
 	*/
	public void setPrevent(String prevent) {
		this.prevent = prevent;
	}
	
	/**
	*药物推荐
 	*medcine_rec
 	*/
	public String getMedcineRec() {
		return medcineRec;
	}
	
	/**
	*药物推荐
 	*medcine_rec
 	*/
	public void setMedcineRec(String medcineRec) {
		this.medcineRec = medcineRec;
	}
	
	/**
	*关键字
 	*keywords
 	*/
	public String getKeywords() {
		return keywords;
	}
	
	/**
	*关键字
 	*keywords
 	*/
	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}
	
	
	
	public String getOdds() {
		return odds;
	}

	public void setOdds(String odds) {
		this.odds = odds;
	}

	/**
	*是否在用,0：未使用,1：正在使用
 	*in_used
 	*/
	public Integer getInUsed() {
		return inUsed;
	}
	
	/**
	*是否在用,0：未使用,1：正在使用
 	*in_used
 	*/
	public void setInUsed(Integer inUsed) {
		this.inUsed = inUsed;
	}
	
	/**
	*
 	*last_modify_time
 	*/
	public Date getLastModifyTime() {
		return lastModifyTime;
	}
	
	/**
	*
 	*last_modify_time
 	*/
	public void setLastModifyTime(Date lastModifyTime) {
		this.lastModifyTime = lastModifyTime;
	}
	
	/**
	*
 	*create_time
 	*/
	public Date getCreateTime() {
		return createTime;
	}
	
	/**
	*
 	*create_time
 	*/
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	
	@Override
	public void dealWith(){
		super.dealWith();
		
	}

	public List<DictDiseaseKey> getDictDiseaseKeyList() {
		return dictDiseaseKeyList;
	}

	public void setDictDiseaseKeyList(List<DictDiseaseKey> dictDiseaseKeyList) {
		this.dictDiseaseKeyList = dictDiseaseKeyList;
	}
	
	public IdNameRes toIdNameRes(){
		return new IdNameRes(id, name);
	}
	
	public List<IdNameRes> getBodyparts() {
		return bodyparts;
	}

	public void setBodyparts(List<IdNameRes> bodyparts) {
		this.bodyparts = bodyparts;
	}

	public void mergeData(){
		if(null == this.getDictDiseaseKeyList() || this.getDictDiseaseKeyList().isEmpty()){
			return ;
		}
    	for(DictDiseaseKey dictDiseaseKey : this.getDictDiseaseKeyList()){
            try {
            	String key = dictDiseaseKey.getKeyName();
            	if(null == key){
            		continue;
            	}
            	Field field = this.getClass().getDeclaredField(key);
            	if(null == field){
            		continue;
            	}
            	Object ojb = field.get(this);
            	if(ojb!=null){
            		dictDiseaseKey.setContent(ojb.toString());
            	}else{
            		dictDiseaseKey.setContent("");
            	}
            	Object obj = field.get(this);
            	dictDiseaseKey.setContent(obj==null? "" : obj.toString());
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (NoSuchFieldException e) {
				e.printStackTrace();
			} catch (SecurityException e) {
				e.printStackTrace();
			} catch (Exception e) {
				Gson gson = new Gson();
				logger.error("Disease.mergeData error,obj={}",gson.toJson(dictDiseaseKey));
			}
    	
    	}
	}
}	